package logic

import (
	"2210a/vipshop/models/mysql"
	"context"
	"gorm.io/gorm"

	"2210a/vipshop/vipshoprpc/internal/svc"
	"2210a/vipshop/vipshoprpc/vipshoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserPerfectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserPerfectLogic {
	return &UserPerfectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserPerfectLogic) UserPerfect(in *vipshoprpc.UserPerfectRequest) (*vipshoprpc.UserPerfectResponse, error) {
	// todo: add your logic here and delete this line
	
	users := mysql.Users{
		Model:       gorm.Model{ID: uint(in.Id)},
		Age:         in.Age,
		NativePlace: in.NativePlace,
		Email:       in.Email,
		Avatar:      in.Avatar,
	}
	mysql.Db.Debug().Updates(&users)
	return &vipshoprpc.UserPerfectResponse{Id: int64(users.ID)}, nil
}
